
/********************************** LICENSE ************************************
 *
 * Copyright 2011 Alessandro Carrega
 * email: alessandro.carrega@unige.it
 *
 * This file is part of insertion_sort_dev.
 *
 * insertion_sort_dev is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * insertion_sort_dev is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with insertion_sort_dev.  If not, see <http://www.gnu.org/licenses/>.
 *
 ********************************* LICENSE ************************************/

void insertion_sort(char *array, int size)
{
  char *start = array + 1;
  char *count = start;

  char *end = array + size;

  while (count < end) {
    char *ind = count;

    while ( ind >= start && *ind < *(ind-1) ) {
      char x = *ind;
      *ind = *(ind - 1);
      *(ind - 1) = x;

      ind--;
    }

    count++;
  }
}

int main(int argc, char **argv)
{
  insertion_sort(argv[1], 5);

  return 0;
}
